#include "GameForm.h"
#include <QtGui/QApplication>
#include <QtGui/QKeyEvent>

GameForm::GameForm(QWidget *parent)
   :QMainWindow(parent){

	setupUi(this);

	connect(newGame, SIGNAL(triggered()), gameField, SLOT(newGame()));
	connect(exit, SIGNAL(triggered()), qApp, SLOT(quit()));
//	connect(aboutGame, SIGNAL(triggered()), SLOT(aboutGame()));
	connect(aboutQt, SIGNAL(triggered(bool)), qApp, SLOT(aboutQt()));

	connect(gameField, SIGNAL(lenSoliter(int)), lenSoliter, SLOT(display(int)));
	connect(gameField, SIGNAL(setLive(int)), live, SLOT(display(int)));
        connect(gameField, SIGNAL(setLevel(int)), level, SLOT(display(int)));
	connect(gameField, SIGNAL(setTarget(int)), target, SLOT(display(int)));

        connect(newGameButton, SIGNAL(clicked()), SLOT(slotNewGame()));
        connect(pauseButton, SIGNAL(clicked()), SLOT(slotPauseGame()));
}

GameForm::~GameForm() {
}

void GameForm::slotNewGame()
{
    gameField->setFocus();
    gameField->newGame();
}

void GameForm::slotPauseGame()
{
    gameField->setFocus();
    QKeyEvent *event = new QKeyEvent(QEvent::KeyPress, Qt::Key_Space, Qt::NoModifier);
    QCoreApplication::postEvent(gameField, event);
}
